#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
class Solution
{
public:
    vector<int> intersection(vector<int> &nums1, vector<int> &nums2)
    {
        map<int, int> mp;
        set<int> st;
        for (int &it : nums1)
        {
            mp[it]++;
        }
        for (int &it : nums2)
        {
            if (mp[it] != 0)
                st.insert(it);
        }
        vector<int> ans(st.begin(), st.end());
        return ans;
    }
};